<?php
class Admin_PaysController extends My_Controller_Admin_Choix
{
	public function indexAction()
	{
	    $numVente = $this->_getParam('num_vente');
	    $paysModel = Mage::getModel('admin/pays');
		$rows = $paysModel->getListPay();

		$this->view->rows = $rows;
	}

	public function editAction()
	{
	    $payId = $this->_getParam('num');
        $this->view->payId = $payId;
        $this->view->payName = '';
        $paysModel = Mage::getModel('admin/pays');
        if ($payId) {
            $pay = $paysModel->load($payId);
            if ($pay) {
                $this->view->payName = $pay->getNom();
            }
        }
	}

	public function newAction()
	{
	   $this->_forward('edit');
	}

	public function deleteAction()
	{
	    $payId = $this->_getParam('num');
	    Mage::getModel('admin/pays')->load($payId)->setDeleted(1)->save();
        $this->_redirect('admin/pays/?num_vente=' . $this->_getParam('num_vente'));
        exit;
	}

	public function saveAction()
	{
        $payName = $this->_getParam('name');
        $payId = $this->_getParam('id');
        $paysModel = Mage::getModel('admin/pays');
        if ($payId) {
            $paysModel->setId($payId);
        }
        $paysModel->setNom($payName)->save();
        $this->_redirect('admin/pays/?num_vente=' . $this->_getParam('num_vente'));
	    exit;
	}
}

